home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 19 / Amiga Plus Leser CD 19.iso / Tools / Freeware / Swf_Player / Lib / character.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-17  |  3.9 KB  |  234 lines

  1. /////////////////////////////////////////////////////////////
  2. // Flash Plugin and Player
  3. // Copyright (C) 1998 Olivier Debon
  4. // 
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. // 
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. // 
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. // 
  19. ///////////////////////////////////////////////////////////////
  20. //  Author : Olivier Debon  <odebon@club-internet.fr>
  21. //  
  22.  
  23. #include "swf.h"
  24.  
  25. #ifdef RCSID
  26. static char *rcsid = "$Id: character.cc,v 1.4 1999/09/03 15:17:40 ode Exp $";
  27. #endif
  28.  
  29. ///// Character member definitions
  30.  
  31. Character::Character(ObjectType objectType, long tagid)
  32. {
  33.     type = objectType;
  34.     tagId = tagid;
  35.     name = NULL;
  36. }
  37.  
  38. Character::~Character()
  39. {
  40.     delete name;
  41. }
  42.  
  43. int
  44. Character::execute(GraphicDevice *gd, Matrix *matrix, Cxform *cxform)
  45. {
  46.     printf("Cannot be executed\n");
  47.     return 0;
  48. }
  49.  
  50. ActionRecord *
  51. Character::eventHandler(GraphicDevice *gd, FlashEvent *ev)
  52. {
  53.     fprintf(stderr,"Unable to handle event !!!\n");
  54.     return 0;
  55. }
  56.  
  57. int
  58. Character::isButton()
  59. {
  60.     return 0;
  61. }
  62.  
  63. int
  64. Character::isSprite(void)
  65. {
  66.     return 0;
  67. }
  68.  
  69. char *
  70. Character::getName()
  71. {
  72.     return name;
  73. }
  74.  
  75. void
  76. Character::getBoundingBox(Rect *bb, DisplayListEntry *e)
  77. {
  78.     //fprintf(stderr,"Unable to handle getBoundingBox !!!\n");
  79.     bb->xmin = LONG_MAX;
  80.     bb->ymin = LONG_MAX;
  81.     bb->ymax = LONG_MIN;
  82.     bb->ymax = LONG_MIN;
  83.     return;
  84. }
  85.  
  86. void
  87. Character::getRegion(GraphicDevice *gd, Matrix *matrix, 
  88.                                void *id, ScanLineFunc scan_line_func)
  89. {
  90.     fprintf(stderr,"Unable to handle getRegion !!!\n");
  91.     return;
  92. }
  93.  
  94. long
  95. Character::getTagId()
  96. {
  97.     return tagId;
  98. }
  99.  
  100. void
  101. Character::reset()
  102. {
  103. }
  104.  
  105. ObjectType
  106. Character::getType()
  107. {
  108.     return type;
  109. }
  110.  
  111. char *
  112. Character::getTypeString()
  113. {
  114.     switch (type) {
  115.         case BitmapType:
  116.             return "Bitmap";
  117.         case FontType:
  118.             return "Font";
  119.         case ButtonType:
  120.             return "Button";
  121.         case SpriteType:
  122.             return "Sprite";
  123.         case ShapeType:
  124.             return "Shape";
  125.         case SoundType:
  126.             return "Sound";
  127.         case TextType:
  128.             return "Text";
  129.         default:
  130.             return "Unknown";
  131.     }
  132. }
  133.  
  134. void
  135. Character::setName(char* string)
  136. {
  137.     name = strdup(string);
  138. }
  139.  
  140. ///// Dict methods definitions
  141.  
  142. Dict::Dict()
  143. {
  144.     head = 0;
  145. }
  146.  
  147. Dict::~Dict()
  148. {
  149.     struct sCharCell *cell,*del;
  150.     
  151.     for(cell = head; cell;)
  152.     {
  153.         del = cell;
  154.         cell = cell->next;
  155.                 delete del->elt;
  156.         delete del;
  157.     }
  158. }
  159.  
  160. void
  161. Dict::addCharacter(Character *character)
  162. {
  163.     struct sCharCell *cell;
  164.  
  165.     cell = new sCharCell;
  166.     if (cell == NULL) {
  167.         delete character;
  168.         return;
  169.     }
  170.     cell->elt = character;
  171.     cell->next = head;
  172.  
  173.     head = cell;
  174. }
  175.  
  176. Character *
  177. Dict::getCharacter(long id)
  178. {
  179.     struct sCharCell *cell;
  180.     
  181.     for(cell = head; cell; cell = cell->next)
  182.     {
  183.         if (id == cell->elt->getTagId()) return cell->elt;
  184.     }
  185.     return 0;
  186. }
  187.  
  188. void
  189. Dict::dictRewind()
  190. {
  191.     currentCell = head;
  192. }
  193.  
  194. Character *
  195. Dict::dictNextCharacter()
  196. {
  197.     if (currentCell) {
  198.         struct sCharCell *cell;
  199.  
  200.         cell = currentCell;
  201.         currentCell = currentCell->next;
  202.         return cell->elt;
  203.     } else {
  204.         return 0;
  205.     }
  206. }
  207.  
  208. void
  209. Dict::nameCharacter(long id, char *string)
  210. {
  211.         struct sCharCell *cell;
  212.  
  213.         for(cell = head; cell; cell = cell->next)
  214.         {
  215.                 if (cell->elt->getTagId() == id) {
  216.                         cell->elt->setName(string);
  217.                         break;
  218.                 }
  219.         }
  220. }
  221.  
  222. #ifdef DUMP
  223. void
  224. Dict::dictSetUnsaved()
  225. {
  226.     struct sCharCell *cell;
  227.     
  228.     for(cell = head; cell; cell = cell->next)
  229.     {
  230.         cell->elt->saved = 0;
  231.     }
  232. }
  233. #endif
  234.